﻿/**
 * Proyecto: Cognitum
 * Global IT Services 2008
 * @author
 */
Cognitum.Polizas.Documento.Entity = function(){
    if (LOG.isDebugEnabled()) {
        LOG.debug('[Cognitum.Polizas.Documento.Entity.ctor] <-');
    }
    Cognitum.Polizas.Documento.Entity.superclass.constructor.call(this);
    this.addEvents({
        'nuevaCarta': true,
        'nuevoDocto': true
    });
}

Ext.extend(Cognitum.Polizas.Documento.Entity, Karma.Core.Entity, {
    id: 'Documento.Entity',
    name: 'Documentos',
    editorXType: 'doc.editor',
    
    columns: [{
        Name: 'Id',
        Property: 'Id',
        Mostrar: false
    }, {
        Name: 'Nombre',
        Property: 'Nombre'
    }, {
        Name: 'Descripcion',
        Property: 'Descripcion'
    }],
    searchlist: {
        grouping: true,
        sortings: ['Nombre'],
        views: [{
            Id: 0,
            Nombre: 'Normal',
            Template: null
        }, {
            Id: 1,
            Nombre: 'Expandida',
            Template: null
        }],
        previewTemplate: null,
        getGridControl: function(){
            var dataview = {
                xtype: 'doc.dataview',
                id: this.getId() + '-grid',
                border: false,
                frame: false,
                store: this.getStore(),
                anchor: '100% 90%',
                height: this.gridH,
                layout: 'anchor',
                listeners: this.getGridListeners(),
                autoHeight: true
            };
            return dataview;
        }
    },
    aggregatelist: {
        onNuevaCarta: function(){
            if (LOG.isDebugEnabled()) {
                LOG.debug('[Documento.AggregateList.onNuevaCarta] <-');
            }
            this.fireEvent('nuevaCarta');
        },
        
        onDigitalizarDocto: function(){
            if (LOG.isDebugEnabled()) {
                LOG.debug('[Documento.AggregateList.onDigitalizarDocto] <-');
            }
            this.fireEvent('nuevoDocto');
        }
    },
    link: {
        displayProperty: 'Nombre'
    },
    getCustomListeners: function(){
        return {
            'nuevaCarta': {
                fn: function(options){
                },
                scope: this
            },
            'nuevoDocto': {
                fn: function(options){
                },
                scope: this
            }
        };
    }
});

Cognitum.Documentos = Cognitum.Polizas.Documento.Entity;
